import { downloadFile } from '@/utils';
import { useThrottleFn } from 'ahooks';
import React from 'react';

type DlBtnProps = {
  onClick?: () => void;
  className?: string | undefined;
  style?: object | undefined;
  children: React.ReactNode;
};

const DlBtn: React.FC<DlBtnProps> = ({ onClick = () => {}, className, style, children }) => {
  const { run } = useThrottleFn(onClick, { wait: 3000, trailing: false });
  return (
    <a onClick={run} className={className} style={style}>
      {children}
    </a>
  );
};

export default DlBtn;
export { downloadFile };
